<? if( $_SESSION[ "JC_account_authority" ] == "administrator" || $_SESSION[ "JC_account_authority" ] == "observer" || JC_organization( 1, $_SESSION[ "JC_account_key" ] ) ) { ?>

	<?

		foreach( $_REQUEST as $key => $value ) $_REQUEST[ $key ] = addslashes( $_REQUEST[ $key ] );



		if( $_REQUEST[ "JC_task_query" ] == "insert" ) {

			$query = "

				INSERT INTO `task` ( `parent`, `priority`, `manager`, `operator`, `type`, `subject`, `content`, `URL`, `period`, `progress`, `insert` )
				VALUES (

					" . (	$_REQUEST[ "JC_task_parent"		] ? "'" . $_REQUEST[ "JC_task_parent"	]  . "'" : "NULL" ) . ",
					'" .	$_REQUEST[ "JC_task_priority"	] . "',
					'" .	$_SESSION[ "JC_account_key"			] . "',
					'" .	$_REQUEST[ "JC_task_operator"	] . "',
					'" .	$_REQUEST[ "JC_task_type"		] . "',
					'" .	$_REQUEST[ "JC_task_subject"		] . "',
					" . (	$_REQUEST[ "JC_task_content"		] ? "'" . $_REQUEST[ "JC_task_content"	]  . "'" : "NULL" ) . ",
					" . (	$_REQUEST[ "JC_task_URL"			] ? "'" . $_REQUEST[ "JC_task_URL"		]  . "'" : "NULL" ) . ",
					" . (	$_REQUEST[ "JC_task_period"		] ? "'" . $_REQUEST[ "JC_task_period"	]  . "'" : "NULL" ) . ",
					'" . $_REQUEST[ "JC_task_progress"		] . "',
					NOW( )

				)

			";

			JC_query( $query );

			JC_LR( );

		}



		if( $_REQUEST[ "JC_task_query" ] == "delete" ) {

			$query = "UPDATE `task` SET `delete` = NOW( ) WHERE `key` = '" . $_REQUEST[ "JC_task_key" ] . "'";

			JC_query( $query );

			JC_LR( '?JC_file=22_task' );

		}



		if( $_REQUEST[ "JC_task_query" ] == "manager" ) {

			$query = "

				UPDATE `task` SET

					`parent`	= " . (	$_REQUEST[ "JC_task_parent"		] ? "'" . $_REQUEST[ "JC_task_parent"	]  . "'" : "NULL" ) . ",
					`priority`	= '" .	$_REQUEST[ "JC_task_priority"	] . "',
					`operator`	= '" .	$_REQUEST[ "JC_task_operator"	] . "',
					`type`		= '" .	$_REQUEST[ "JC_task_type"		] . "',
					`subject`	= '" .	$_REQUEST[ "JC_task_subject"		] . "',
					`content`	= " . (	$_REQUEST[ "JC_task_content"		] ? "'" . $_REQUEST[ "JC_task_content"	]  . "'" : "NULL" ) . ",
					`URL`		= " . (	$_REQUEST[ "JC_task_URL"			] ? "'" . $_REQUEST[ "JC_task_URL"		]  . "'" : "NULL" ) . ",
					`period`	= " . (	$_REQUEST[ "JC_task_period"		] ? "'" . $_REQUEST[ "JC_task_period"	]  . "'" : "NULL" ) . ",
					`update`	= NOW( )

				WHERE `key` = '" . $_REQUEST[ "JC_task_key" ] . "'

			";

			JC_query( $query );

			JC_LR( );

		}



		if( $_REQUEST[ "JC_task_query" ] == "report" ) {

			$query = "SELECT * FROM `task` WHERE `key` = '" . $_REQUEST[ "JC_task_key" ] . "'";

			$RS = JC_query( $query );

			if( $RS ) $record = $RS -> fetch_array( );

			foreach( array( 'parent', 'priority', 'operator', 'type', 'content', 'URL', 'period', 'progress' ) as $key => $value )
				if( $_REQUEST[ "JC_task_" . $value ] != $record[ $value ] )
					$_REQUEST[ "JC_task_report" ] .= ( $_REQUEST[ "JC_task_report" ] ? "\r\n" : "" ) . ucwords( $value ) . " → " . $_REQUEST[ "JC_task_" . $value ];

			echo $query = "
				INSERT INTO `report` (
					`account`,
					`task`,
					`content`,
					`insert`
				) VALUES (
					'" . $_SESSION[ "JC_account_key"	] . "',
					'" . $_REQUEST[ "JC_task_key"	] . "',
					'" . $_REQUEST[ "JC_task_report"	] . "',
					NOW( )
				)
			";

			JC_query( $query );

			JC_LR( );

		}

	?>



	<?

		////
		///
		//	Operator

	?>

	<b>Task</b> - Operator<br /><hr />

	<table>

		<tr>
			<th>Key</th>
			<th title="Parent"		class="help">↔</th>
			<th title="Priority"	class="help">↕</th>
			<th>Manager</th>
			<th title="Type"		class="help">T</th>
			<th>Subject</th>
			<th>Content</tH>
			<th>URL</tH>
			<th>Period</tH>
			<th title="Progress"	class="help">P</tH>
			<th>Report</th>
			<th>Today</th>
		</tr>

		<?

			$query = "
				SELECT
					*,
					( SELECT `name` FROM `account` WHERE `key` = `manager`		) AS `manager FKF`,
					( SELECT `name` FROM `account` WHERE `key` = `operator`	) AS `operator FKF`,
					( SELECT COUNT( `key` ) FROM `report` WHERE `report`.`task` = `task`.`key` AND SUBSTR( `insert`, 1, 10 ) = '" . date( "Y-m-d" ). "' ) AS `today`,
					`JC_sort_task`( `key` ) AS `order`
				FROM `task`
				WHERE `delete` IS NULL
				AND `operator` = '" . $_SESSION[ "JC_account_key" ] . "'
				AND ( `progress` != 'has been finished' OR ( `progress` = 'has been finished' AND SUBSTR( `update`, 1, 10 ) = '" . date( "Y-m-d" ). "'  ) )
				ORDER BY `order` DESC
			";

			$RS = JC_query( $query );

			$count = 0;

			while( $record = $RS -> fetch_array( ) ) { $count ++;

		?>

			<tr <?= $count % 2 == 0 ? "class='whitesmoke'" : "" ?>>

				<td class="right form silver"><?= $record[ "key" ] ?></td>

				<td class="right form silver"><?= $record[ "parent" ] ?></td>

				<td class="right form silver"><?= $record[ "priority" ] ?></td>

				<td class="form silver"><?= $record[ "manager FKF" ] ?></td>

				<td class="form">
				
					<?

						switch( $record[ "type" ] ) {

							case "public":	echo "<span title='public'	class='help'		>…</span>"; break;
							case "private":	echo "<span title='private'	class='help red'	>●</span>"; break;

						}

					?>

				</td>

				<td class="form black">
					<? for( $i = 0; $i < substr_count( $record[ "order"	], ";" ) - 1; $i ++ ) echo "&nbsp; "; ?>
					<?= $record[ "subject" ] ?>
				</td>

				<td><textarea title="<?= $record[ "content" ] ?>" cols="12" rows="1" class="dimgray" readonly><?= $record[ "content" ] ?></textarea></td>

				<td class="form">

					<? if( $record[ "URL" ] ) foreach( JC_TA( $record[ "URL" ], null, "\r\n" ) as $key => $value ) { $temporary = explode( "/", $value );?>

						<a href="<?= $value ?>" title="<?= $value ?>" target="_blank" class="dimgray"><?= $temporary[ 2 ] ?></a><br />

					<? } ?>

				</td>

				<td class="form"><?= $record[ "period" ] ?></td>

				<td class="form">

					<?

						switch( $record[ "progress" ] ) {

							case "will be started":				echo "<span title='will be started'				class='help'		>…</span>"; break;
							case "will be finished on time":	echo "<span title='will be finished on time'	class='help blue'	>●</span>"; break;
							case "will be delayed":				echo "<span title='will be delayed'				class='help red'	>●</span>"; break;
							case "has been finished":			echo "<span title='has been finished'			class='help silver'	>●</span>"; break;

						}

					?>

				</td>

				<td>

					<?

						$temporary = "";

						$RS_report = JC_query( "SELECT `account`, `content`, `insert` FROM `report` WHERE `delete` IS NULL AND `task` = '" . $record[ "key" ] . "' ORDER BY `insert` DESC" );

						if( $RS ) while( $record_report = $RS_report -> fetch_array( ) ) $temporary .= $record_report[ "insert" ] . " " . $record_report[ "account" ] . "\r\n" . $record_report[ "content" ] . "\r\n\r\n";

					?>

					<textarea title="<?= $temporary ?>" cols="12" rows="1" readonly><?= $temporary ?></textarea>

				</td>

				<td class="right form <?= $record[ "today" ] ? "" : "red" ?>"><?= $record[ "today" ] ?></td>

			</tr>

		<? } ?>

	</table><br /><hr />



	<b>Task</b> - Report<br /><hr />

	<table>

		<tr>
			<th>Key</th>
			<th title="Parent"		class="help">↔</th>
			<th title="Priority"	class="help">↕</th>
			<th title="Operator"	class="help">O</th>
			<th>Type</th>
			<th>Subject</th>
			<th>Content</tH>
			<th>URL</tH>
			<th>Period</tH>
			<th>Progress</tH>
			<th>Report</th>
			<th>Today</th>
			<th>Insert</th>
		</tr>

		<?

			$query = "
				SELECT
					*,
					( SELECT `name` FROM `account` WHERE `key` = `manager`		) AS `manager FKF`,
					( SELECT `name` FROM `account` WHERE `key` = `operator`	) AS `operator FKF`,
					( SELECT COUNT( `key` ) FROM `report` WHERE `report`.`task` = `task`.`key` AND SUBSTR( `insert`, 1, 10 ) = '" . date( "Y-m-d" ). "' ) AS `today`,
					`JC_sort_task`( `key` ) AS `order`
				FROM `task`
				WHERE `delete` IS NULL
				AND `operator` = '" . $_SESSION[ "JC_account_key" ] . "'
				AND ( `progress` != 'has been finished' OR ( `progress` = 'has been finished' AND SUBSTR( `update`, 1, 10 ) = '" . date( "Y-m-d" ). "'  ) )
				ORDER BY `order` DESC
			";

			$RS = JC_query( $query );

			$count = 0;

			while( $record = $RS -> fetch_array( ) ) { $count ++;

		?>

			<form id="JC_task_report_<?= $record[ "key" ] ?>" target="JC_asynchronous" method="post">

				<input type="hidden" name="JC_task_query" value="report" />

				<tr <?= $count % 2 == 0 ? "class='whitesmoke'" : "" ?>>

					<td class="right form">

						<?= $record[ "key" ] ?>
						<input type="hidden" name="JC_task_key" value="<?= $record[ "key" ] ?>" />

					</td>

					<td>

						<select name="JC_task_parent" style="width: 45px;">

							<option></option>

							<?

								$query = "SELECT `key`, `subject` FROM `task`";

								$RS_parent = JC_query( $query );

								while( $record_parent = $RS_parent -> fetch_array( ) ) {

							?>

								<option value="<?= $record_parent[ "key" ] ?>" <?= $record[ "parent" ] == $record_parent[ "key" ] ? "selected" : "" ?>><?= $record_parent[ "key" ] ?>: <?= $record_parent[ "subject" ] ?></option>

							<? } ?>

						</select>

					</td>

					<td>

						<select name="JC_task_priority" class="right" style="width: 45px;">

							<? for( $i = 127; $i > -129; $i -- ) { ?>

								<option <?= $record[ "priority" ] == $i ? "selected" : "" ?>><?= $i ?></option>

							<? } ?>

						</select>

					</td>

					<td class="silver">

						<input type="hidden" name="JC_task_manager" value="<?= $record[ "manager" ] ?>" />

						<select name="JC_task_operator" style="width: 45px;">

							<? foreach( JC_organization( 1 ) as $key => $value ) { ?>

								<option value="<?= $key ?>" <?= $record[ "operator" ] == $key ? "selected" : "" ?>><?= $key ?>: <?= $value ?></option>

							<? } ?>

						</select>

					</td>

					<td>

						<select name="JC_task_type" style="width: 45px;">

							<? foreach( explode( ',', $_SESSION[ "JC_scheme" ][ "task" ][ "type" ][ "option" ] ) as $key => $value ) { ?>

								<option <?= $record[ "type" ] == trim( $value ) ? "selected" : "" ?>><?= trim( $value ) ?></option>

							<? } ?>

						</select>

					</td>

					<td class="black">
						<? for( $i = 0; $i < substr_count( $record[ "order"	], ";" ) - 1; $i ++ ) echo "&nbsp; "; ?>
						<input type="text" name="JC_task_subject" value="<?= $record[ "subject" ] ?>" title="<?= $record[ "subject" ] ?>" size="12" />
					</td>

					<td><textarea name="JC_task_content"	title="<?= $record[ "content" ] ?>"	cols="6" rows="1"><?= $record[ "content"	] ?></textarea></td>

					<td><textarea name="JC_task_URL"		title="<?= $record[ "URL" ] ?>"		cols="6" rows="1"><?= $record[ "URL"		] ?></textarea></td>

					<td><input type="text" name="JC_task_period" value="<?= $record[ "period" ] ?>" title="<?= $record[ "period" ] ?>" size="6" /></td>

					<td>

						<select name="JC_task_progress" style="width: 90px;">

							<? foreach( explode( ',', $_SESSION[ "JC_scheme" ][ "task" ][ "progress" ][ "option" ] ) as $key => $value ) { ?>

								<option <?= $record[ "progress" ] == trim( $value ) ? "selected" : "" ?>><?= trim( $value ) ?></option>

							<? } ?>

						</select>

					</td>

					<td><textarea name="JC_task_report" title="<?= $record[ "report" ] ?>" cols="24" rows="4"><?= $record[ "report" ] ?></textarea></td>

					<td class="right form <?= $record[ "today" ] ? "" : "red" ?>"><?= $record[ "today" ] ?></td>

					<td><a href="#this" class="form" onclick="document.getElementById( 'JC_task_report_<?= $record[ "key" ] ?>' ).submit( );">Insert</a></td>

				</tr>

			</form>

		<? } ?>

	</table><br /><hr />



	<?

		////
		///
		//	Public

	?>

	<b>Task</b> - Public<br /><hr />

	<table>

		<tr>
			<th>Key</th>
			<th title="Parent"		class="help">↔</th>
			<th title="Priority"	class="help">↕</th>
			<th>Manager</th>
			<th>Operator</th>
			<th title="Type"		class="help">T</th>
			<th>Subject</th>
			<th>Content</tH>
			<th>URL</tH>
			<th>Period</tH>
			<th title="Progress"	class="help">P</tH>
			<th>Report</th>
			<th>Today</th>
		</tr>

		<?

			$query = "
				SELECT
					*,
					( SELECT `name` FROM `account` WHERE `key` = `manager`		) AS `manager FKF`,
					( SELECT `name` FROM `account` WHERE `key` = `operator`	) AS `operator FKF`,
					( SELECT COUNT( `key` ) FROM `report` WHERE `report`.`task` = `task`.`key` AND SUBSTR( `insert`, 1, 10 ) = '" . date( "Y-m-d" ). "' ) AS `today`,
					`JC_sort_task`( `key` ) AS `order`
				FROM `task`
				WHERE `delete` IS NULL
				AND `operator` != '" . $_SESSION[ "JC_account_key" ] . "'
				AND ( `type` = 'public' OR `manager` = '" . $_SESSION[ "JC_account_key" ] . "' )
				ORDER BY `order` DESC
			";

			$RS = JC_query( $query );

			$count = 0;

			while( $record = $RS -> fetch_array( ) ) { $count ++;

		?>

			<tr <?= $count % 2 == 0 ? "class='whitesmoke'" : "" ?>>

				<td class="right form silver"><?= $record[ "key" ] ?></td>

				<td class="right form silver"><?= $record[ "parent" ] ?></td>

				<td class="right form silver"><?= $record[ "priority" ] ?></td>

				<td class="form silver"><?= $record[ "manager FKF" ] ?></td>

				<td class="form silver"><?= $record[ "operator FKF" ] ?></td>

				<td class="form">
				
					<?

						switch( $record[ "type" ] ) {

							case "public":	echo "<span title='public'	class='help'		>…</span>"; break;
							case "private":	echo "<span title='private'	class='help red'	>●</span>"; break;

						}

					?>

				</td>

				<td class="form black">
					<? for( $i = 0; $i < substr_count( $record[ "order"	], ";" ) - 1; $i ++ ) echo "&nbsp; "; ?>
					<?= $record[ "subject" ] ?>
				</td>

				<td><textarea title="<?= $record[ "content" ] ?>" cols="12" rows="1" class="dimgray" readonly><?= $record[ "content" ] ?></textarea></td>

				<td class="form">

					<? if( $record[ "URL" ] ) foreach( JC_TA( $record[ "URL" ], null, "\r\n" ) as $key => $value ) { $temporary = explode( "/", $value );?>

						<a href="<?= $value ?>" title="<?= $value ?>" target="_blank" class="dimgray"><?= $temporary[ 2 ] ?></a><br />

					<? } ?>

				</td>

				<td class="form"><?= $record[ "period" ] ?></td>

				<td class="form">

					<?

						switch( $record[ "progress" ] ) {

							case "will be started":				echo "<span title='will be started'				class='help'		>…</span>"; break;
							case "will be finished on time":	echo "<span title='will be finished on time'	class='help blue'	>●</span>"; break;
							case "will be delayed":				echo "<span title='will be delayed'				class='help red'	>●</span>"; break;
							case "has been finished":			echo "<span title='has been finished'			class='help silver'	>●</span>"; break;

						}

					?>

				</td>

				<td>

					<?

						$temporary = "";

						$RS_report = JC_query( "SELECT `account`, `content`, `insert` FROM `report` WHERE `delete` IS NULL AND `task` = '" . $record[ "key" ] . "' ORDER BY `insert` DESC" );

						if( $RS ) while( $record_report = $RS_report -> fetch_array( ) ) $temporary .= $record_report[ "insert" ] . " " . $record_report[ "account" ] . "\r\n" . $record_report[ "content" ] . "\r\n\r\n";

					?>

					<textarea title="<?= $temporary ?>" cols="12" rows="1" readonly><?= $temporary ?></textarea>

				</td>

				<td class="right form <?= $record[ "today" ] ? "" : "red" ?>"><?= $record[ "today" ] ?></td>

			</tr>

		<? } ?>

	</table><br /><hr />



	<?

		////
		///
		//	Manager

	?>

	<b>Task</b> - Manager<br /><hr />

	<table>

		<tr>
			<th>Key</th>
			<th>Parent</th>
			<th>Priority</th>
			<th>Operator</th>
			<th>Type</th>
			<th>Subject</th>
			<th>Content</tH>
			<th>URL</tH>
			<th>Period</tH>
			<th title="Progress"	class="help">P</tH>
			<th>Report</th>
			<th>Today</th>
			<th>Update</th>
			<th>Delete</th>
		</tr>

		<?

			$query = "
				SELECT
					*,
					( SELECT `name` FROM `account` WHERE `key` = `manager`		) AS `manager FKF`,
					( SELECT `name` FROM `account` WHERE `key` = `operator`	) AS `operator FKF`,
					( SELECT COUNT( `key` ) FROM `report` WHERE `report`.`task` = `task`.`key` AND SUBSTR( `insert`, 1, 10 ) = '" . date( "Y-m-d" ). "' ) AS `today`,
					`JC_sort_task`( `key` ) AS `order`
				FROM `task`
				WHERE `delete` IS NULL
				AND `manager` = '" . $_SESSION[ "JC_account_key" ] . "'
				ORDER BY `order` DESC
			";

			$RS = JC_query( $query );

			$count = 0;

			while( $record = $RS -> fetch_array( ) ) { $count ++;

		?>

			<form id="JC_task_manager_<?= $record[ "key" ] ?>" target="JC_asynchronous" method="post">

				<input type="hidden" name="JC_task_query" value="manager" />

				<tr <?= $count % 2 == 0 ? "class='whitesmoke'" : "" ?>>

					<td class="right form">
						<?= $record[ "key" ] ?>
						<input type="hidden" name="JC_task_key" value="<?= $record[ "key" ] ?>" />
					</td>

					<td>

						<select name="JC_task_parent" style="width: 60px;">

							<option></option>

							<?

								$query = "SELECT `key`, `subject` FROM `task`";

								$RS_parent = JC_query( $query );

								while( $record_parent = $RS_parent -> fetch_array( ) ) {

							?>

								<option value="<?= $record_parent[ "key" ] ?>" <?= $record[ "parent" ] == $record_parent[ "key" ] ? "selected" : "" ?>><?= $record_parent[ "key" ] ?>: <?= $record_parent[ "subject" ] ?></option>

							<? } ?>

						</select>

					</td>

					<td>

						<select name="JC_task_priority" class="right">

							<? for( $i = 127; $i > -129; $i -- ) { ?>

								<option <?= $record[ "priority" ] == $i ? "selected" : "" ?>><?= $i ?></option>

							<? } ?>

						</select>

					</td>

					<td class="silver">

						<select name="JC_task_operator" style="width: 90px;">

							<? foreach( JC_organization( 1 ) as $key => $value ) { ?>

								<option value="<?= $key ?>" <?= $record[ "operator" ] == $key ? "selected" : "" ?>><?= $value ?></option>

							<? } ?>

						</select>

					</td>

					<td>

						<select name="JC_task_type" style="width: 45px;">

							<? foreach( explode( ',', $_SESSION[ "JC_scheme" ][ "task" ][ "type" ][ "option" ] ) as $key => $value ) { ?>

								<option <?= $record[ "type" ] == trim( $value ) ? "selected" : "" ?>><?= trim( $value ) ?></option>

							<? } ?>

						</select>

					</td>

					<td class="black">
						<? for( $i = 0; $i < substr_count( $record[ "order"	], ";" ) - 1; $i ++ ) echo "&nbsp; "; ?>
						<input type="text" name="JC_task_subject" value="<?= $record[ "subject" ] ?>" title="<?= $record[ "subject" ] ?>" size="24" />
					</td>

					<td><textarea name="JC_task_content"	title="<?= $record[ "content" ] ?>"	cols="12" rows="1"><?= $record[ "content"	] ?></textarea></td>

					<td><textarea name="JC_task_URL"		title="<?= $record[ "URL" ] ?>"		cols="12" rows="1"><?= $record[ "URL"		] ?></textarea></td>

					<td><input type="text" name="JC_task_period" value="<?= $record[ "period" ] ?>" title="<?= $record[ "period" ] ?>" size="12" /></td>

					<td>

						<select name="JC_task_progress" style="width: 90px;">

							<? foreach( explode( ',', $_SESSION[ "JC_scheme" ][ "task" ][ "progress" ][ "option" ] ) as $key => $value ) { ?>

								<option <?= $record[ "progress" ] == trim( $value ) ? "selected" : "" ?>><?= trim( $value ) ?></option>

							<? } ?>

						</select>

					</td>

					<td>

						<?

							$temporary = "";

							$RS_report = JC_query( "SELECT `account`, `content`, `insert` FROM `report` WHERE `delete` IS NULL AND `task` = '" . $record[ "key" ] . "' ORDER BY `insert` DESC" );

							if( $RS ) while( $record_report = $RS_report -> fetch_array( ) ) $temporary .= $record_report[ "insert" ] . " " . $record_report[ "account" ] . "\r\n" . $record_report[ "content" ] . "\r\n\r\n";

						?>

						<textarea title="<?= $temporary ?>" cols="12" rows="1" readonly><?= $temporary ?></textarea>

					</td>

					<td class="right form <?= $record[ "today" ] ? "" : "red" ?>"><?= $record[ "today" ] ?></td>

					<td><a href="#this" class="form" onclick="if( confirm( 'Update?' ) ) document.getElementById( 'JC_task_manager_<?= $record[ "key" ] ?>' ).submit( );">Update</a></td>

					<td><a href="#this" class="form" onclick="if( confirm( 'Delete?' ) ) document.getElementById( 'JC_asynchronous' ).src = '?JC_file=22_task&JC_task_query=delete&JC_task_key=<?= $record[ "key" ] ?>';">Delete</a></td>

				</tr>

			</form>

		<? } ?>

	</table><br /><hr />



	<?

		////
		///
		//	Insert

	?>

	<b>Task</b> - Insert<br /><hr />

	<form id="JC_task_insert" target="JC_asynchronous" method="post">

		<input type="hidden" name="JC_task_query" value="insert" />

		<table>

			<tr>
				<th>Parent</th>
				<th>Priority</th>
				<th>Manager</th>
				<th>Operator</th>
				<th>Type</th>
				<th>Subject</th>
				<th>Content</tH>
				<th>URL</tH>
				<th>Period</tH>
				<th>Progress</tH>
				<th>Insert</tH>
			</tr>

			<tr>

				<td>

					<select name="JC_task_parent" style="width: 45px;">

						<option></option>

						<?

							$query = "SELECT `key`, `subject` FROM `task`";

							$RS = JC_query( $query );

							while( $record = $RS -> fetch_array( ) ) {

						?>

							<option value="<?= $record[ "key" ] ?>"><?= $record[ "key" ] ?>: <?= $record[ "subject" ] ?></option>

						<? } ?>

					</select>

				</td>

				<td>

					<select name="JC_task_priority" class="right" style="width: 45px;">

						<? for( $i = 127; $i > -129; $i -- ) { ?>

							<option <?= $i == 0 ? "selected" : "" ?>><?= $i ?></option>

						<? } ?>

					</select>

				</td>

				<td class="form"><?= $_SESSION[ "JC_account_name" ] ?></td>

				<td>

					<select name="JC_task_operator" style="width: 45px;">

						<? foreach( JC_organization( 1 ) as $key => $value ) { ?>

							<option value="<?= $key ?>" <?= $record[ "operator" ] == $key ? "selected" : "" ?>><?= $key ?>: <?= $value ?></option>

						<? } ?>

					</select>

				</td>

				<td>

					<select name="JC_task_type" style="width: 45px;">

						<? foreach( explode( ',', $_SESSION[ "JC_scheme" ][ "task" ][ "type" ][ "option" ] ) as $key => $value ) { ?>

							<option><?= trim( $value ) ?></option>

						<? } ?>

					</select>

				</td>

				<td><input		type="text"	name="JC_task_subject"	size="24"			onchange="this.title = this.value;" /></td>

				<td><textarea				name="JC_task_content"	cols="24" rows="4"	onchange="this.title = this.value;" ></textarea></td>

				<td><textarea				name="JC_task_URL"		cols="24" rows="4"	onchange="this.title = this.value;" ></textarea></td>

				<td><input		type="text" name="JC_task_period"	size="12"			onchange="this.title = this.value;" /></td>

				<td>

					<select name="JC_task_progress" style="width: 90px;">

						<? foreach( explode( ',', $_SESSION[ "JC_scheme" ][ "task" ][ "progress" ][ "option" ] ) as $key => $value ) { ?>

							<option><?= $value ?></option>

						<? } ?>

					</select>

				</td>

				<td><a href="#this" class="form" onclick="document.getElementById( 'JC_task_insert' ).submit( );">Insert</a></td>

			</tr>

		</table>

	</form>

<? } ?>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           